/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.net.InetAddress;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Observable;
import java.util.Set;
import chatGUI.*;
/**
 *
 * @author doutre
 */
public class Users extends Observable {

    private HashMap<InetAddress,User> userList;
    private HashMap<InetAddress,ChatWindow> windows;
    

    public Users() {
        this.userList = new HashMap<InetAddress, User>();
        this.windows = new HashMap<InetAddress,ChatWindow>();
    }

    public HashMap getUserList() {
        
        return this.userList;
    }

    public HashMap<InetAddress, ChatWindow> getWindows() {
        return windows;
    }
    
   
    public void ajout(User utilisateur) {
        userList.put(utilisateur.getIp(),utilisateur);
        setChanged();
        notifyObservers(userList);
        
    }
     public void suppr(InetAddress addr) {
        userList.remove(addr);
        setChanged();
        notifyObservers(userList);
        
    }
     
    
     public ChatWindow nouv_conv(User u,ChatController.ChatController cc){
         ChatWindow w = new ChatWindow(u,cc);
         this.windows.put(u.getIp(),w);
         return w;
     }
     
   
    
}
